//package android.cmpe451.group7.dbrequest;
//
//import java.io.BufferedInputStream;
//import java.io.BufferedOutputStream;
//import java.io.ByteArrayOutputStream;
//import java.io.Closeable;
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.OutputStream;
//import java.lang.ref.WeakReference;
//import java.net.URL;
//import java.util.List;
//
//import org.apache.http.HttpEntity;
//import org.apache.http.HttpResponse;
//import org.apache.http.HttpStatus;
//import org.apache.http.client.methods.HttpGet;
//
//import android.app.Activity;
//import android.cmpe451.group7.activity.PictureActivity;
//import android.cmpe451.group7.activity.R;
//import android.cmpe451.group7.entity.Comment;
//import android.cmpe451.group7.entity.Multimedia;
//import android.content.Context;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.net.http.AndroidHttpClient;
//import android.os.AsyncTask;
//import android.util.Log;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.ArrayAdapter;
//import android.widget.ImageView;
//import android.widget.ListView;
//import android.widget.TextView;
//
//public abstract class ImageDownloaderTask extends
//		AsyncTask<String, Void, List<Bitmap>> {
//	private static final int IO_BUFFER_SIZE = 4 * 1024;
//	protected Activity activity;
//	List<Long> multimediaIds;
//
//	public ImageDownloaderTask(List<Long> ids) {
//		multimediaIds = ids;
//	}
//
//	// Actual download method, run in the task thread
//	@Override
//	protected List<Bitmap> doInBackground(String... params) {
//		// params comes from the execute() call: params[0] is the url.
//		return downloadBitmap(params[0]);
//	}
//
//	// Once the image is downloaded, associates it to the imageView
//	@Override
//	protected abstract void onPostExecute(List<Bitmap> bitmap);
//
//	// {
//	// bitmapPicture = bitmap;
//	// if (isCancelled()) {
//	// bitmap = null;
//	// }
//	//
//	// PictureResponse.multimediaAdapter = new MultimediaArrayAdapter(
//	// activity, android.R.layout.simple_list_item_1, bitmap);
//	//
//	// PictureResponse.multimediaAdapter.notifyDataSetChanged();
//	// PictureActivity.listView.setAdapter(PictureResponse.multimediaAdapter);
//	// }
//
//	private Bitmap downloadBitmap(String url) {
//		Bitmap bitmap = null;
//		InputStream in = null;
//		BufferedOutputStream out = null;
//
//		try {
//			in = new BufferedInputStream(new URL(url).openStream(),
//					IO_BUFFER_SIZE);
//
//			final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
//			out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE);
//			copy(in, out);
//			out.flush();
//
//			final byte[] data = dataStream.toByteArray();
//			bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
//		} catch (IOException e) {
//
//		} finally {
//			closeStream(in);
//			closeStream(out);
//		}
//
//		return bitmap;
//	}
//
//	private void closeStream(Closeable stream) {
//		if (stream != null) {
//			try {
//				stream.close();
//			} catch (IOException e) {
//			}
//		}
//	}
//
//	private void copy(InputStream in, OutputStream out) throws IOException {
//		byte[] b = new byte[IO_BUFFER_SIZE];
//		int read;
//		while ((read = in.read(b)) != -1) {
//			out.write(b, 0, read);
//		}
//	}
//}
